<?php
	header('Content-Type:text/html;Charset=utf-8');
	header("Access-Control-Allow-Origin:*");
	header("Access-Control-Allow-Methods:GET,POST");	
	// 用系统变量_POST拿到表单提交的数据
	$name=$_POST["name"];
	$score=$_POST["score"];
	//将拿到的数据提交给数据库
	//(1)连接process数据库
	$conn=mysqli_connect('localhost:3306','root','sdo2605587','process');
	// $conn=mysqli_connect('127.0.0.1','root','sdo2605587','process');
	if (mysqli_connect_error()) {
    die("数据库连接失败: " . mysqli_connect_error());
	}
	//为数据库指定字符集
	mysqli_query($conn,'SET NAMES utf8');
	//发送SQL语句
	$sql="INSERT INTO score (id,name,score) VALUES (null,'$name',$score)";
	$result=mysqli_query($conn,$sql);
	$affectedRows = -1;
	if($result){//执行成功后，读取上述SQL语句影响的行数
		$affectedRows = mysqli_affected_rows($conn);
		echo $affectedRows;
	}else{
		echo "插入失败，请查询原因";
	}
?>